/*******************************************************************************
 * Copyright (c) 2002 Boris Pruessmann and others. All rights reserved. This
 * program and the accompanying materials are made available under the terms of
 * the Common Public License v0.5 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors: Boris Pruessmann - Initial implementation.
 ******************************************************************************/
package net.sourceforge.perforce.core.internal.events;

import net.sourceforge.perforce.core.syncinfo.IResourceStateDelta;
import net.sourceforge.perforce.core.syncinfo.ResourceSyncInfo;

import org.eclipse.core.resources.IResource;

/**
 * @version $Revision: 488 $
 * @author <a href="mailto:bpruessmann@users.sourceforge.net">Boris
 *         Pruessmann</a>
 */
public class ResourceStateDelta implements IResourceStateDelta {
  // ---------------------------------------------------------------------------
  // Private Variables

  /** Kind of change. */
  private int kind;
  /** Stores the handle to the resource. */
  private IResource resource;
  /** Stores the handle to the old ResourceSyncInfo. */
  private ResourceSyncInfo oldResourceSyncInfo;
  /** Stores the reference to the new ResourceSyncInfo. */
  private ResourceSyncInfo newResourceSyncInfo;

  // -------------------------------------------------------------------------
  // Public Constructors

  /**
   * Constructor for ResourceStateDelta.
   * 
   * @param kind the kind of change.
   * @param theResource the resource.
   * @param oldSyncInfo the old ResourceSyncInfo.
   * @param newSyncInfo the new ResourceSyncInfo.
   */
  public ResourceStateDelta(int kind, IResource theResource, ResourceSyncInfo oldSyncInfo,
      ResourceSyncInfo newSyncInfo) {
    this.kind = kind;
    resource = theResource;
    oldResourceSyncInfo = (oldSyncInfo != ResourceSyncInfo.NULL_INFO) ? oldSyncInfo : null;
    newResourceSyncInfo = (newSyncInfo != ResourceSyncInfo.NULL_INFO) ? newSyncInfo : null;
  }

  //----------------------------------------------------------------------------
  // -- Public Methods

  /** @see net.sourceforge.perforce.core.syncinfo.IResourceStateDelta#getKind() */
  public int getKind() {
    return kind;
  }

  /**
   * Returns the resource.
   * 
   * @return the resource.
   */
  public IResource getResource() {
    return resource;
  }

  /**
   * Returns the new ResourceSyncInfo.
   * 
   * @return new ResourceSyncInfo.
   */
  public ResourceSyncInfo getNewResourceSyncInfo() {
    return newResourceSyncInfo;
  }

  /**
   * Returns the oldResourceSyncInfo.
   * 
   * @return old ResourceSyncInfo
   */
  public ResourceSyncInfo getOldResourceSyncInfo() {
    return oldResourceSyncInfo;
  }
}
